package com.zhss.eshop.commodity.mapper;

import com.zhss.eshop.commodity.domain.model.CommodityGoods;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface CommodityGoodsMapper {
    int deleteByPrimaryKey(Long id);

    int insertSelective(CommodityGoods record);

    CommodityGoods selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(CommodityGoods record);

    /**
     * 根据类目id查询商品数量
     * @param categoryId 类目id
     * @return 商品数量
     */
    @Select("SELECT count(*) "
            + "FROM commodity_goods "
            + "WHERE category_id=#{categoryId}")
    Long countByCategoryId(@Param("categoryId") Long categoryId);
}
